using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MeetingRoom.Data.Implementation;
using MeetingRoom.Service.Workflow.Implementation;

namespace MeetingRoom.Service.Workflow
{
    /// <summary>
    /// Summary description for HardWiredWorkflowInitializer
    /// </summary>
    public sealed class HardWiredWorkflowInitializer
    {
        private static readonly HardWiredWorkflowInitializer instance = new HardWiredWorkflowInitializer();

        protected IDictionary<string, IWorkflow> workflows = new Dictionary<string, IWorkflow>();

        private HardWiredWorkflowInitializer()
        {
            AddSchedule addSchedule = new AddSchedule();
            addSchedule.Create = new ScheduleCreate();

            IWorkflowPhase availablibiltyChecking = new AvailablityCheckingPhase();

            IWorkflow workflow = new SimpleWorkflow();
            workflow.AddPreCondition(availablibiltyChecking);
            workflow.AddPostCondition(addSchedule);

            this.workflows.Add("add request", workflow);
        }

        public static HardWiredWorkflowInitializer GetInstance()
        {
            return HardWiredWorkflowInitializer.instance;
        }

        public IWorkflow GetWorkflow(string workflowName)
        {
            return this.workflows[workflowName];
        }
    }
}